﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Engine.Graphics
{
    public enum SpawnArea
    {
        Point,
        Box,
        Circle,
        Ring,
        Line
    }

    public class ParticleEngine : DrawableGameComponent
    {
        public bool IsActive = false;

        private static ParticleEngine mInstance;
        public static ParticleEngine Instance { get { return mInstance; } }

        public int ParticleCount { get; private set; }
        public List<ParticleSystem> systems;

        public ParticleEngine(Game _game) : base(_game)
        {
            systems = new List<ParticleSystem>();
            mInstance = this;
        }

        public static GameObject InitializeNewSystem(string _presetName, Vector2 _position, GameObject _parent = null)
        {
            GameObject newSystem = GameObject.Initialize(_presetName, _position, _parent,
                                                         new Dictionary<Type, object[]>
                                                         {
                                                             {typeof(ParticleSystem), new object[] {ParticleSystemDatabase.ParticleSystemPresets[_presetName]}},
                                                         });
            return newSystem;
        }

        #region DrawableGameComponent Overrides
        public override void Update(GameTime gameTime)
        {         
            base.Update(gameTime);
            ParticleCount = 0;
            foreach (ParticleSystem sys in systems)
                ParticleCount += sys.ParticleCount;
        }

        #endregion


    }
}
